Ext.ns('AIR2.Import.Resolve');
/***************
 * Import Resolver Fact Panel
 *
 * A panel that allows conflict resolution of a fact
 *
 * @param {Object} data
 * @param {String} model
 */
AIR2.Import.Resolve.Fact = function(data, model) {
    // get fact data, from list of TankFacts
    var factID = model.substr(5);
    var tankFact;
    for (var i=0; i<data.TankFact.length; i++) {
        if (data.TankFact[i].tf_fact_id == factID) {
            tankFact = data.TankFact[i];
        }
    }

    // Get the resource URL for the production SrcFact
    var factUrl = null;
    if (data.src_uuid && tankFact.Fact.fact_uuid) {
        factUrl = AIR2.HOMEURL + '/source/' + data.src_uuid + '/facts/'+tankFact.Fact.fact_uuid+'.json';
    }

    return new AIR2.Import.Resolve.ConflictRow({
        model: model,
        tpl: new Ext.XTemplate(
            '<ul><tpl for=".">' +
                '<tpl if="sf_src_value"><li class="sf_src_value"><b>Raw Text:</b> {sf_src_value}</li></tpl>' +
                '<tpl if="AnalystFV"><li class="sf_fv_id"><b>Analyst Mapped:</b> {[values.AnalystFV.fv_value]}</li></tpl>' +
                '<tpl if="SourceFV"><li class="sf_src_fv_id"><b>Source Mapped:</b> {[values.SourceFV.fv_value]}</li></tpl>' +
            '</tpl></ul>',
            {compiled:true, disableFormats:true}
        ),
        currTitle: tankFact.Fact.fact_name,
        currUrl: factUrl,
        newData: tankFact,
        validOps: 'REPLACE|IGNORE'
    });
}